Use case: DMA channel direct mode transfer in polling mode

Sequence diagram

DMA channel direct mode transfer in polling mode.

  @startuml
  hide footbox
  participant "User Application" as part1
  participant "DMA Driver"       as part3

  group Configuration
  part1->part3 : HAL_DMA_Init()
  end

  group Process
      group  Start
          part1->part3 : HAL_DMA_Start()
      end
      group  Polling for transfer
          part1->part3 : HAL_DMA_PollForTransfer()
          part3->part1:
      end
  end

  @enduml

Code snippet

HAL1

HAL2

HAL_DMA_Init(&hdma1);


HAL_DMA_Start(&hdma, (uint32_t)srcAddress, (uint32_t)dstAddress
                                                 , dataSize);

HAL_DMA_PollForTransfer(&hdma, HAL_DMA_FULL_TRANSFER, timeout);
HAL_DMA_Init(&hdma1, GPDMA1_CH0);
HAL_DMA_SetConfigDirectXfer(&hdma1, directXferConfig);

HAL_DMA_StartDirectXfer(&hdma, (uint32_t)srcAddress, (uint32_t)dstAddress
                                                     , dataSize * multiplier);

HAL_DMA_PollForXfer(&hdma, HAL_DMA_XFER_FULL_COMPLETE, timeout);

Key changes

  1. HAL2 requires explicit direct-transfer configuration using HAL_DMA_SetConfigDirectXfer() (or HAL_DMA_SetConfigPeriphDirectXfer()).

  2. HAL2 starts transfers using HAL_DMA_StartDirectXfer() and polls using HAL_DMA_PollForXfer().

  3. Depending on the series, the transfer size may need to be expressed in bytes or beats (see the note in the main DMA use-cases page).